var layerId;
$(function(){
	$("#search-button").click(function(){
		var keyword=$("input[name='keyword']").val();
		var brandId=$("select[name='goodsBrand']").val();
		var categoryId=$("select[name='goodsCategory']").val();
		var goodsStatus=$("select[name='goodsStatus']").val();
		var isSp=$("select[name='goodsisSp']").val();
		var timeStart=$("input[name='timeStart']").val();
		var timeEnd=$("input[name='timeEnd']").val();
		var url=basePath+"/goods/searchGoodsInfo.shtml?pageNo="+1+"&pageSize="+10+"&keyword="+keyword
		+"&goodsStatus="+goodsStatus+"&brandId="+brandId+"&isSp="+isSp+"&categoryId="+categoryId
		+"&timeStart="+timeStart+"&timeEnd="+timeEnd;
		window.location.href=url;
	})
	$("#add-button").click(function(){
		layerId=layer.open({
			title: "商品信息编辑",
			area: ['1200px','850px'],
			fix:true,
			type: 2,
			maxmin:true,
			content: basePath+'/goods/add.shtml'
		});
	});
	$("#updateSolr-button").click(function(){
		$.ajax({
	   		 url:basePath+"/goods/updateSolr.shtml",  
	   		 type:"get",
	   		 dataType:"JSON",
	   		 success:function(data){
	   			 if(data.code=="000000"){
	   				layer.msg("操作成功");
	   				setTimeout(function(){    
						self.location.reload(true);
					}, 1000);
	   			 }else{
	   				 layer.msg(data.msg);
	   			 }
	   		 },error:function(data){
	   		 }
	   	 });
	})
})
function openEdit(goodsId){
	layerId=layer.open({
		title: "商品信息编辑",
		area: ['1200px','850px'],
		fix:true,
		type: 2,
		maxmin:true,
		content: basePath+'/goods/edit.shtml?goodsId='+goodsId
	});
}
function closeLayer(){
	if(layerId>0)
		layer.close(layerId);
	self.location.reload(true); 
}
function showGoodsDetail(goodsId){
	var openUrl=H5GoodsUrl+goodsId;
	layerId=layer.open({
		title: "商品详情",
		area: ['414px','763px'],
		fix:true,
		type: 2,
		content: openUrl,
	});
}
function updateStatus(goodsId,status){
	 $.ajax({
   		 url:basePath+"/goods/updateStatus.shtml?goodsId="+goodsId+"&status="+status,  
   		 type:"get",
   		 dataType:"JSON",
   		 success:function(data){
   			 if(data.code=="000000"){
   				layer.msg("操作成功");
   				setTimeout(function(){    
					self.location.reload(true);
				}, 1000);
   			 }else{
   				 layer.msg(data.msg);
   			 }
   		 },error:function(data){
   		 }
   	 });
}
function fanye(pageNo){
	var url=basePath+"/goods/searchGoodsInfo.shtml?pageNo="+pageNo+"&keyword="+init.keyword
	+"&goodsStatus="+init.goodsStatus+"&brandId="+init.brandId+"&isSp="+init.isSp+"&categoryId="+init.categoryId+"&timeStart="+init.timeStart
	+"&timeEnd="+init.timeEnd;
	window.location.href=url;
}



